Skip to content

fix: load .env, open the app after activation, re-check licenses - #2

Merged
catsika merged 2 commits into
mainfrom
fix/env-health-check
Oct 17, 2026
Merged

catsika merged 2 commits into
mainfrom
fix/env-health-check

Conversation

@catsika

@catsika catsika commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Problems

  1. Quick Start crashed. .env was never loaded, so KEYMINT_CLIENT_API_KEY was empty and new KeyMint('') threw on startup.
  2. The app never opened after activation. The activation dialog closed itself and nothing called createMainWindow(); on Windows/Linux the app quit.
  3. No real health check. The README promised re-validation, but launch only read the stored flag, and checkLicenseHealth was never called. It also treated SDK exceptions (which the SDK throws on every non-2xx) the same as network errors.

Change

  • dotenv loads .env first. The SDK client is created lazily, and missing config shows a message instead of crashing.
  • The main window opens on the activation event, before the dialog closes.
  • Re-validate on launch and every 24h: 401/402/403 → license rejected → back to activation; offline/429/5xx → keep cached state.
  • Shared store.ts, events.ts (avoids an ipc ↔ index circular import), optional KEYMINT_BASE_URL, and a README that matches the code.

Testing

  • npm run build passes.
  • The compiled license.js was run against a local Keymint API (no GUI):
    • a valid key activates and checks as valid;
    • a bogus key and a blocked key check as rejected;
    • an unreachable server checks as unknown, with a "could not reach" message;
    • missing config shows the configuration message, with no crash.
  • Not tested: clicking through the GUI windows.

- Load .env with dotenv. Previously the documented `cp .env.example .env`
  flow left the key empty and `new KeyMint('')` threw at startup.
- Create the SDK client lazily and show a configuration message instead of
  crashing when the variables are missing.
- Open the main window when activation succeeds. Before, the activation
  dialog closed itself and nothing opened the app (it quit on Windows/Linux).
- Re-validate on launch and every 24 hours. The SDK throws on non-2xx, so
  treat 401/402/403 as a rejected license and anything else (offline, 429,
  5xx) as unknown, keeping the cached state.
- Optional KEYMINT_BASE_URL; README matches the code.
Keymint returns 404 when the product is deleted or deactivated, or the
license was removed. Treating it as transient kept the cached license
valid indefinitely; it now logs the user out like 401/402/403.
@catsika

catsika commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

Reviewed 2026-10-17: npm ci and npm run build (tsc) are clean. Added one commit: activation 404s (product deleted or deactivated, license removed) now count as a rejected license, matching the Keymint API (LicenseKeyApiService returns 404 for these). Before, they were treated as transient and kept the cached license valid indefinitely.

@catsika
catsika force-pushed the fix/env-health-check branch from 08c4d4c to 9a819f2 Compare October 17, 2026 23:42
@catsika
catsika marked this pull request as ready for review October 17, 2026 23:51
@catsika
catsika merged commit d2e87f1 into main Oct 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant